Private Sub Command1_Click()

'Make a selection in the active document, copy it to the clipboard and paste it into a new document

Dim appRef As Photoshop.Application
Dim docRef As Photoshop.Document
Dim newDocRef As Photoshop.Document
Dim selectionType As Photoshop.PsSelectionType
Dim textureType As Photoshop.PsTextureType
Dim selectionRef As Photoshop.Selection

Set appRef = New Photoshop.Application

If (appRef.Documents.Count >= 1) Then

    appRef.Preferences.RulerUnits = psPixels
    appRef.DisplayDialogs = psDisplayNoDialogs
    
    Set docRef = appRef.ActiveDocument
    
    selectionType = psReplaceSelection
    docRef.Selection.Select Array(Array(50, 60), Array(150, 60), Array(150, 120), Array(50, 120)), Type:=selectionType, Feather:=10, AntiAlias:=False
    
    ' Get the document selection and copy it to the clipboard.
    ' If there is a selection the entire document gets copied.
    ' Then create a new document and paste the selection to the new document.

    Set selectionRef = docRef.Selection
    docRef.Selection.Copy
    
    Set newDocRef = appRef.Documents.Add(400, 400)
    newDocRef.Paste
    
Else
    MsgBox ("There must be at least one open document")
End If

End Sub
